﻿using System;
using Inovout.Serializer;
using Newtonsoft.Json.Serialization;

namespace Inovout.Data.Repository
{
    public class NHibernateContractResolver : InterfaceContractResolver
    {
        public NHibernateContractResolver(Type type)
            :base(type)
        {}
        protected override JsonContract CreateContract(Type objectType)
        {
            if (typeof(NHibernate.Proxy.INHibernateProxy).IsAssignableFrom(objectType))
            {
                return base.CreateContract(objectType.BaseType);
            }
            return base.CreateContract(objectType);
        }
    }
}
